package com.example.mobile2030606148tdh0415d;

import android.content.DialogInterface;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.app.AppCompatActivity;

public class MainActivity2 extends AppCompatActivity {

    private TextView tvMainTitle;
    private TextView tvMainTitle2;
    private TextView tvMainShangpin;
    private TextView tvMainResult;
    private Button btnMainClose;
    private Button btnMainTijiao;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main2);
        initView();
        btnMainTijiao.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                String[] supplies={"新星汽车配件","枫叶汽车配件","天辉汽车配件","西末汽车配件"};
                new AlertDialog.Builder(MainActivity2.this).setTitle("请选中供应商!")
                        .setPositiveButton("确定", new DialogInterface.OnClickListener() {
                            @Override
                            public void onClick(DialogInterface dialogInterface, int which) {
                                dialogInterface.dismiss();
                            }
                        })
                        .setSingleChoiceItems(supplies, 0, new DialogInterface.OnClickListener() {
                            @Override
                            public void onClick(DialogInterface dialog, int which) {
                                tvMainResult.setText(supplies[which]);
                            }
                        })

                        .create().show();

            }
        });
    }

    private void initView() {
        tvMainTitle = (TextView) findViewById(R.id.tv_main_title);
        tvMainTitle2 = (TextView) findViewById(R.id.tv_main_title2);
        tvMainShangpin = (TextView) findViewById(R.id.tv_main_shangpin);
        tvMainResult = (TextView) findViewById(R.id.tv_main_result);
        btnMainClose = (Button) findViewById(R.id.btn_main_Close);
        btnMainTijiao = (Button) findViewById(R.id.btn_main_tijiao);
    }
}